package com.bj58.migrate.main;

import java.util.Calendar;
import java.util.Date;

import com.bj58.migrate.task.Task;
import org.apache.log4j.Logger;

import com.bj58.zhaopin.app.engine.context.AppContext;
import com.bj58.zhaopin.app.engine.task.QuartzTask;

public class FangBao1 extends QuartzTask {
	
	private Logger logger = Logger.getLogger(FangBao1.class);

	@Override
	public String quartzExprsion() {
		Date date = getDate(new Date(), 1);//明天
		
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		int second = calendar.get(Calendar.SECOND);
		second = 0;
		int minute = calendar.get(Calendar.MINUTE);
		minute = 0;
		int hour = calendar.get(Calendar.HOUR_OF_DAY);
		hour = 1;
		int month = calendar.get(Calendar.MONTH) + 1;
		int day = calendar.get(Calendar.DATE);
		int year = calendar.get(Calendar.YEAR);
		logger.info("Fangbao1 "+ second+" "+minute+" "+hour+" "+day+" "+month+" ?");
		return second+" "+minute+" "+hour+" "+day+" "+month+" ?";
	}

	@Override
	public void destory() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void init(AppContext arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void start() {
		logger.info("Fangbao1 start~~~~");
		String[] args = { "fr", "fb" ,"1"};
		
		Task task = new Task(args);
		task.run( args );
	}
	
	private Date getDate(Date now,int internel){
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(now);
		
		calendar.add(Calendar.MINUTE, 5);
		calendar.add(Calendar.DATE, internel);
		return calendar.getTime();
	}

//	public static void main( String[] args ){
//
//		if( args != null && args.length > 1 ){
//
//			MigrateTask task = new MigrateTask( args );
//			task.run( args );
//		}
//	}
}
